import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//引入elementui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

// 引入echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts;

//引入axios
import axios from 'axios'
import VueAxios from 'vue-axios'
axios.defaults.baseURL="http://localhost:3000"
Vue.use(VueAxios,axios)


Vue.use(ElementUI);

Vue.config.productionTip = false

//创建全局路由守卫，判断用户是否登录
router.beforeEach((to,from,next)=>{
	if(to.meta.requireAuth){
		if(store.state.admin){
			next()
		}else{
      alert('请先登录')
      next({path:'/'})
		}
	}else{
		next()
	}
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
